package com.aptemo.webetek.client.widgets;

import com.google.gwt.event.dom.client.BlurEvent;
import com.google.gwt.event.dom.client.BlurHandler;
import com.google.gwt.event.dom.client.FocusEvent;
import com.google.gwt.event.dom.client.FocusHandler;
import com.google.gwt.user.client.ui.TextBox;

public class FocusTextBox
		extends TextBox implements FocusHandler, BlurHandler
{

	public static final String	CSS_FOCUS_TEXTBOX		= "focusTextBox";
	public static final String	CSS_FOCUSED				= "focused";
	public static final String	CSS_FOCUS_TEXTBOX_EMPTY	= "focusTextBoxEmpty";

	public FocusTextBox()
	{
		super();
		setStyleName(CSS_FOCUS_TEXTBOX);

		addFocusHandler(this);
		addBlurHandler(this);
	}

	@Override
	public void onFocus(FocusEvent event)
	{
		if (!isReadOnly())
		{
			addStyleName(CSS_FOCUSED);
			removeStyleName(CSS_FOCUS_TEXTBOX_EMPTY);
			// super.selectAll();
		}
	}

	@Override
	public void onBlur(BlurEvent event)
	{
		removeStyleName(CSS_FOCUSED);
	}

//	public void setFocusedStyle(boolean style)
//	{
//		if (style == true)
//		{
//			addStyleName(CSS_FOCUSED);
//		}
//		else
//		{
//			removeStyleName(CSS_FOCUSED);
//		}
//	}
}
